//
// Created by 39442 on 2025/10/4.
//

#ifndef THREAD_POOL_MYTHREAD_H
#define THREAD_POOL_MYTHREAD_H

#include <thread>
#include <functional>

class MyThread {
public:
    //线程函数对象类型
    using ThreadFunc = std::function<void(int)>;

    explicit MyThread(ThreadFunc func);
    ~MyThread();

    //启动线程
    void start();

    //获取线程id
    [[nodiscard]] int getId() const;
private:
    ThreadFunc func_;
    static int generateId_;
    int threadId_;	//保存线程id
};

#endif //THREAD_POOL_MYTHREAD_H